//
//  ConfigData.m
//  wtshoppingcite
//
//  Created by Baojia-LC on 14/11/21.
//  Copyright (c) 2014年 TW. All rights reserved.
//

#import "ConfigData.h"

#define LAST_RUN_VERSION_KEY @"last_run_version_of_application"

@implementation ConfigData


+ (instancetype)sharedInstance
{
    static ConfigData *instance = nil;
    static dispatch_once_t once;
    dispatch_once(&once, ^{
        instance = [[ConfigData alloc] init];
        instance.udid = [[UIDevice currentDevice] getDeviceUniqueID];
    });
    return instance;
}

- (BOOL)isFirstLaunch
{
    NSString *currentVersion = [[[NSBundle mainBundle] infoDictionary]
                                objectForKey:@"CFBundleShortVersionString"];
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    NSString *lastRunVersion = [defaults objectForKey:LAST_RUN_VERSION_KEY];
    if (!lastRunVersion) {
        [defaults setObject:currentVersion forKey:LAST_RUN_VERSION_KEY];
        return YES;
    }else if (![lastRunVersion isEqualToString:currentVersion]) {
        [defaults setObject:currentVersion forKey:LAST_RUN_VERSION_KEY];
        return YES;
    }
    return NO;
}

@end
